package com.hspedu.newData.dmsxl.动态规划;
/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-05-25 
 * @Version: 1.0
 */

public class LC53最大子数组和 {

    public int maxSubArray(int[] nums) {
        int pre = 0;
        int max = nums[0];

        for (int i = 0; i < nums.length; i++) {
            pre = Math.max(pre+nums[i],nums[i]);
            max = Math.max(max,pre);
        }

        return max;
    }
}
